/*
 * FAtoms.cpp
 *
 *  Created on: May 13, 2012
 *      Author: marchi
 */

#include "FAtoms.h"

void FAtoms::ReadaStep(std::ifstream & fin){
	double table[6];
	matrix coo;
	fin.seekg(FORTRANBYTES,ios::cur);
	fin.read(reinterpret_cast<char *> (&table),sizeof(table));
	fin.seekg(FORTRANBYTES,ios::cur);
	for(int o=0;o<DIM;o++)
		for(int p=0;p<DIM;p++)
			coo[o][p]=0.0;

	coo[XX][XX]=table[0]*unit_nm;
	coo[YY][YY]=table[2]*unit_nm;
	coo[ZZ][ZZ]=table[5]*unit_nm;

	Metric Met(coo);
	vector<float> X[DIM];

	for(int i=0;i<DIM;i++){
		X[i].resize(nr,0.0);
		fin.seekg(FORTRANBYTES,ios::cur);
		fin.read(reinterpret_cast<char *> (&X[i][0]),sizeof(X[0][0])*nr);
		fin.seekg(FORTRANBYTES,ios::cur);
	}
	rvec * x=new rvec[nr];
	for(int n=0;n<nr;n++){
		for(int o=0;o<DIM;o++) x[n][o]=X[o][n]*unit_nm;
	}
	setCoord(Met,x);
	doCOtoOC();
}
FAtoms::~FAtoms() {
	// TODO Auto-generated destructor stub
}

